<template>
	<view class="content">
		<view class='card'>
			<view class='cardtitle'>邀请注册链接</view>
			<uv-text @click="onCopy(url)" size="34rpx" type="primary" :text="url"></uv-text>
		</view>
		<view class='card'>
			<view class='cardtitle'>邀请注册二维码</view>
			<image v-if="qrimg" :src='qrimg' mode="widthFix"></image>
			<view v-if="qrimg" style="text-align: center;font-size: 34rpx;margin-top: 30rpx;">请长按保存二维码图或者截图保存分享</view>
		</view>
		<uqrcode ref="uqrcode" canvas-id="qrcode" :value="url" :options="{ margin: 10 }" :auto="false" :hide="true" @complete="createPoster"></uqrcode>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url:'',
				qrimg:'',
			}
		},
		onLoad() {
			var t = this;
			this.util.post('agent',{op:'reglink'},(r)=>{
				t.url = r.url;
			})
		},
		methods: {
			onCopy(txt){
				uni.setClipboardData({
					data:txt
				})
			},
			createPoster(res) {
				var that = this;
				this.$refs.uqrcode.toTempFilePath({
				  success: ures => {
					  that.qrimg = ures.tempFilePath
				  }
				});
			},
		}
	}
</script>

<style lang="scss">
.content{
	background: #f4f5f9;
	height: 100vh;
	padding: 30rpx 0;
}
</style>
